#====# Appendix O: Describing FCPA enforcement and OECD ABC enforcement #====#

# Load libraries and set defaults ----
library(tidyverse)
library(tidylog, warn.conflicts = FALSE)

# Import data ----
ABC <- read_rds("data/OECD_ABC_enf.rds") # ABC enforcement data from Crippa, Malesky, Picci (2025)

# Appendix O text ----
ABC %>%
  reframe(across(.cols = c("cases", "cases_hqUS", "enf_us", "cases_hqNOTUS_enf_US"),
                 .fns = ~sum(.x, na.rm = TRUE))) %>%
  pivot_longer(cols = everything()) %>%
  mutate(tot = value[name == "cases"],
         perc = 100*value/tot,
         name = case_when(name == "cases" ~ "Any enforcer, any firm",
                          name == "cases_hqUS" ~ "Any enforcer, US firms",
                          name == "enf_us" ~ "US enforcement (FCPA), any firm",
                          name == "cases_hqNOTUS_enf_US" ~ "US enforcement (FCPA), non-US firms")) %>%
  select(-tot) %>%
  rename("Type of case" = "name",
         "Total cases" = "value",
         "Percentage of total" = "perc")
# these numbers are reported in the Appendix O text (not as a table)

#====# The End #====#